/*REPLICATION CODE FOR 
Kam, Cindy D. and Colette Marcellin. "Unwilling to Disclose: Privacy and Pregnancy in Post-Roe America." Public Opinion Quarterly.
*/

*Analyses performed with Stata/SE 17.0
*Analyses require installation of: coefplot, estout
cd "C:\Users\kamcd\Dropbox\CDK WORK\period privacy\Kam Marcellin Replication Data\"
log using "Kam Marcellin Replication file", replace

//Dataset compiled from BRFSS to include 2017-2022, excluding 2020
use "C:\Users\kamcd\Dropbox\CDK WORK\period privacy\Kam Marcellin Replication Data\BRFSS2017_2022", clear

*****Declare survey design*****
svyset [pweight = _llcpwt], strata(_ststr) psu(_psu) singleunit(centered)

*******************************
*Recoding Variables*

*****Temporal Variables*****
gen year = iyear
destring year, force replace
destring iday, gen(day_no) force
destring imonth, gen(month_no) force
destring iyear, gen(year_no) force
gen numdate = date(idate,"MDY")
gen int week_num = wofd(numdate) - wofd(td(31dec2016))
gen monthdate = ym(year,month_no)

*creating yearly dummies
recode year (2022=1)(2016/2021=0)(else=.), gen(yr2022)
recode year (2021=1)(2016/2019 2022=0)(else=.), gen(yr2021)
recode year (2019=1)(2016/2018 2021 2022=0)(else=.), gen(yr2019)
recode year (2018=1)(2016 2017 2019/2022=0)(else=.), gen(yr2018)
recode year (2017=1)(2016 2018/2022=0)(else=.), gen(yr2017)
lab var yr2022 "2022"
lab var yr2021 "2021"
lab var yr2019 "2019"
lab var yr2018 "2018"
lab var yr2017 "2017"

*creating monthly dummies
forval v =1(1)12 {
	recode month_no (`v'=1)(else=0), gen(month_`v')
}
lab var month_1 "Jan"
lab var month_2 "Feb"
lab var month_3 "Mar"
lab var month_4 "Apr"
lab var month_5 "May"
lab var month_6 "Jun"
lab var month_7 "Jul"
lab var month_8 "Aug"
lab var month_9 "Sep"
lab var month_10 "Oct"
lab var month_11 "Nov"
lab var month_12 "Dec"

*Dobbs decision was released on June 24, 2022*
recode month_no (1/6=0 "Jan - June")(7/12=1 "Jun24Dec31"), gen(Jun24Dec31)
replace Jun24Dec31=1 if month_no==6 & day_no>23
lab var Jun24Dec31 "June 24-Dec 31"

*new monthly variables that move last week of June into July
gen month_7r=month_7
replace month_7r=1 if month_no==6 & day_no>23
lab var month_7r "July+"
gen month_6r=month_6
replace month_6r=0 if month_no==6 & day_no>23
lab var month_6r "June*"
gen newmonthly = month_no
replace newmonthly =7 if month_no==6 & day_no>23
lab def newmonthly 1"Jan" 2"Feb" 3 "Mar" 4 "Apr" 5 "May" 6 "Jun*" 7 "Jul+" 8 "Aug" 9 "Sep" 10 "Oct" 11 "Nov" 12 "Dec"
lab val newmonthly newmonthly

*****Key DV*****
recode pregnant (9=1 "Ref")(1 2 7 =0 "Not Ref"), gen(pregnant_REF)
recode pregnant (9=100 "Ref")(1 2 7 =0 "Not Ref"), gen(pregnant_REF100)

*****Control Variables*****
lab def _educa 1"<HS" 2"HS" 3"Some College/Tech" 4"BA" 9"Ref", modify
lab val _educa _educa
recode _educag (1=1)(2/9=0)(else=.), gen(lesshs)
recode _educag (2=1)(1 3/9=0)(else=.), gen(hsdeg)
recode _educag (3=1)(1 2 4/9=0)(else=.), gen(somecol)
recode _educag (4=1)(1 2 3 9=0)(else=.), gen(college)
gen hsorless = lesshs
replace hsorless = 1 if hsdeg==1

gen race = _imprace
lab def race 1"non-Hispanic white only" 2"non-Hispanic Black only" 3"Asian" 4"American Indian or Alaskan Native only" 5"Hispanic" 6"Other race"
lab val race race

recode race (1=1)(2/6=0)(else=.), gen(white)
recode race (2=1)(1 3/6=0)(else=.), gen(black)
recode race (3=1)(1 2 4/6=0)(else=.), gen(asian)
recode race (4 6=1)(1/3 5=0)(else=.), gen(amind_oth)
recode race (5=1)(1/4 6=0)(else=.), gen(hispanic)

lab def agecat 1"18-24" 2"25-29" 3"30-34" 4"35-39" 5"40-44" 6"45-49" 14"DK/ref/missing"
lab val _ageg5yr agecat
//remove the one person age 80 who was asked the pregnancy question
drop if _ageg5yr==13 & pregnant<999
recode _ageg5yr (1 2=1)(3/99=0)(else=.), gen(age1829)
recode _ageg5yr (3 4=1)(1/2 5/99=0)(else=.), gen(age3039)
recode _ageg5yr (5 6=1)(1/4 7/99=0)(else=.), gen(age4049)

lab def income3 1"<10K" 2"10K-15K" 3"15K-20K" 4"20K-25K" 5"25K-35K" 6"35K-50K" 7"50K-75K" 8"75K-100K" 9"100K-150K" 10"150K-200K" 11">200K" 77"DK/Not sure" 99"Ref"
lab val income3 income3
recode income3 (1=1)(2=2)(3=3)(4=4)(5=5)(6=6)(7=7)(8 9 10 11=8)(77=77)(99=99)(else=.), gen(new_income)
replace new_income = income2 if year==2019
replace new_income = income2 if year==2018
replace new_income = income2 if year==2017
lab def new_income 1"<10K" 2"10K-15K" 3"15K-20K" 4"20K-25K" 5"25K-35K" 6"35K-50K" 7"50K-75K" 8">75K" 77"DK/Not sure" 99"Ref", modify
lab val new_income new_income
lab val income2 new_income

*sex of respondent
recode sexvar (1=1)(2=0)(else=.), gen(male)

*******************************
**********TABLE 1**********
svy, subpop(yr2022): tab newmonthly pregnant, row percent format(%9.2f)
svy, subpop(yr2022): tab newmonthly pregnant, obs format(%9.2f)

**********FIGURE 1**********
set scheme s1mono
svy, subpop(yr2022): reg pregnant_REF100 month_2 month_3 month_4 month_5 month_6r month_7r month_8 month_9 month_10 month_11 month_12 i.race i._ageg5yr i._educa i.new_income
est store monthly2022
gen preg_sample22= e(sample)
coefplot monthly2022, yline(0) vertical title("Monthly Indicators") keep(month_2 month_3 month_4 month_5 month_6r month_7r month_8 month_9 month_10 month_11 month_12 ) name(monthly2022, replace) xlabel(, labsize(small))

svy, subpop(yr2022): reg pregnant_REF100 Jun24Dec31 i.race i._ageg5yr i._educa i.new_income
est store Jun24Dec31

coefplot Jun24Dec31, yline(0) vertical title(" Pre- vs. Post- Dobbs") keep(Jun24Dec31) name(Jun24Dec31, replace)

graph combine monthly2022 Jun24Dec31, ycommon ysize(2.5) xsize(4)
graph export Figure1.tif, replace width(4000)

estout monthly2022 Jun24Dec31 using Appendix.txt, replace cells(b(fmt(3)) se(fmt(3)) p(fmt(3))) stats(r2 N, fmt(%9.3f %9.0g)) delimit(|) lab title("Table SB1")

*******************************
*ANALYZING ALL YEARS
gen Jun24Dec31yr2022=Jun24Dec31*yr2022
svy: reg pregnant_REF100 Jun24Dec31yr2022 yr2022 Jun24Dec31 i.race i._ageg5yr i._educa i.new_income yr2018 yr2019 yr2021
est store DiD
gen preg_sample = e(sample)

recode genhlth (1/7=0)(9=100)(else=.), gen(health_REF100)
svy, subpop(preg_sample): reg health_REF100 Jun24Dec31yr2022 yr2022 Jun24Dec31 i.race i._ageg5yr i._educa i.new_income yr2018 yr2019 yr2021
est store health_REF

//FN: missing six observations somewhere between genhlth & pregnant
gen missing = .
replace missing =1 if pregnant_REF<2 & health_REF==.
browse if missing==1
//these six observations are spread across years; just were not administered the Q. missing data on genhlth

estout DiD health_REF using Appendix.txt, append cells(b(fmt(3)) se(fmt(3)) p(fmt(3))) stats(r2 N N_sub, fmt(%9.3f %9.0g)) delimit(|) lab title("Table SB2")

**********TABLE 2**********
estout DiD health_REF, cells(b(fmt(3)) se(fmt(3)) p(fmt(3))) stats(r2 N N_sub, fmt(%9.3f %9.0g)) delimit(|) lab title("Table 2") keep(Jun24Dec31yr2022 yr2022 Jun24Dec31)

**********TABLE 3**********
est restore DiD
predict pregnant_REF_hat
predict pregnant_REF_se, stdp
svy, subpop(preg_sample): mean pregnant_REF_hat, over(Jun24Dec31 yr2022)
**********TABLE 3**********

*******************************
*MULTINOMINAL LOGIT
svy: mlogit pregnant Jun24Dec31yr2022 yr2022 Jun24Dec31 i.race i._ageg5yr i._educa i.new_income yr2018 yr2019 yr2021
est store mlogit
estout mlogit using Appendix.txt, append cells(b(fmt(3)) se(fmt(3)) p(fmt(3))) stats(p N, fmt(%9.3f %9.0g)) delimit(|) lab title("Table SB3") unstack eqlabels("DK vs. No" "Yes vs. No" "DK vs. No") keep(9: 1: 7:) order(9: 1: 7:)

*******************************

*******************************
*****OTHER PLACEBO ITEMS*****
recode cervscrn (9=100 "Ref")(1 2 7 =0 "Not Ref"), gen(cervscrn_REF100)
recode marijan1 (99=100 "Ref")(1 /88 =0 "Not Ref"), gen(marijan1_REF100)
recode sofemale (9=100 "Ref")(1/7=0 "Not Ref")(else=.), gen(sexor_REF100)
*Supplementary Materials Table SB4
svy, subpop(preg_sample): mean pregnant_REF100  health_REF100  cervscrn_REF100  marijan1_REF100 sexor_REF100

svy, subpop(preg_sample): reg cervscrn_REF100 Jun24Dec31yr2022 yr2022 Jun24Dec31 i.race i._ageg5yr i._educa i.new_income yr2018 yr2019 yr2021
est store cervscrn_REF
svy, subpop(preg_sample): reg marijan1_REF100 Jun24Dec31yr2022 yr2022 Jun24Dec31 i.race i._ageg5yr i._educa i.new_income yr2018 yr2019 yr2021
est store marijan1_REF
svy, subpop(preg_sample): reg sexor_REF100 Jun24Dec31yr2022 yr2022 Jun24Dec31 i.race i._ageg5yr i._educa i.new_income yr2018 yr2019 yr2021
est store sexor_REF
svy, subpop(male): reg health_REF100 Jun24Dec31yr2022 yr2022 Jun24Dec31 i.race i._ageg5yr i._educa i.new_income yr2018 yr2019 yr2021
est store genhlth_M

lab var Jun24Dec31yr2022 "June 24-Dec 31 x 2022"
lab var Jun24Dec31 "June 24-Dec 31"
lab var yr2022 "2022"

coefplot DiD health_REF cervscrn_REF marijan1_REF sexor_REF genhlth_M, keep(Jun24Dec31yr2022 yr2022 Jun24Dec31) yline(0) plotlabels("Pregnancy Q" "Gen Health" "Cervical Screening" "Marijuana Use" "Sexual Orientation" "Gen Health: Men") title("Modeling Refusal on Key & Placebo Items") name(placebos, replace) note("Sample: Women <50 except as noted", pos(5)) caption("OLS Coefficients on Key Variables with 95% CI", pos(5)) vertical
graph export AppFigC4.tif, replace width(800) height(600)

*******************************

*******************************
*****ITS MODELS*****
gen intervention = Jun24Dec31yr2022

*monthly running variable
gen monthdate_r = monthdate-750
replace monthdate_r =0 if Jun24Dec31==1 & monthdate==749
gen interventionmonth_r= intervention*monthdate_r
svy: reg pregnant_REF100 monthdate_r intervention interventionmonth_r i.race i._ageg5yr i._educa i.new_income yr2018 yr2019 yr2021 yr2022
est store itsmonthly
gen preg_sample_its=e(sample)

*weekly running variable
gen week_num_r = week_num -286
replace week_num_r = 0 if week_num ==285 & Jun24Dec31yr2022==1
gen interventionweek_r = intervention*week_num_r
svy: reg pregnant_REF100 week_num_r intervention interventionweek_r i.race i._ageg5yr i._educa i.new_income  yr2018 yr2019 yr2021 yr2022
est store itsweekly

*daily running variable
gen numdate_r = numdate-22820
gen interventionday_r = intervention*numdate_r
svy: reg pregnant_REF100 numdate_r intervention interventionday_r i.race i._ageg5yr i._educa i.new_income yr2018 yr2019 yr2021 yr2022
est store itsdaily

//compared with general health
svy, subpop(preg_sample_its): reg health_REF100 monthdate_r intervention interventionmonth_r i.race i._ageg5yr i._educa i.new_income yr2018 yr2019 yr2021 yr2022
est store itsmonthlyhealth
svy, subpop(preg_sample_its): reg health_REF100 week_num_r intervention interventionweek_r i.race i._ageg5yr i._educa i.new_income  yr2018 yr2019 yr2021 yr2022
est store itsweeklyhealth
svy, subpop(preg_sample_its): reg health_REF100 numdate_r intervention interventionday_r i.race i._ageg5yr i._educa i.new_income yr2018 yr2019 yr2021 yr2022
est store itsdailyhealth

estout itsmonthly itsweekly itsdaily itsmonthlyhealth itsweeklyhealth itsdailyhealth using Appendix.txt, append cells(b(fmt(3)) se(fmt(3)) p(fmt(3))) stats(r2 N N_sub, fmt(%9.3f %9.0g)) delimit(|) lab title("Table SB5")

**********HETEROGENEITY ANALYSIS**********
*****focusing on 2022 only*****
drop if year~=2022

**********DEMOGRAPHICS**********
*****POWER ANALYSIS*****
*FN: effect size
svy, subpop(yr2022): reg pregnant_REF100 Jun24Dec31 i.race i._ageg5yr i._educa i.new_income
gen yr2022sample = e(sample)
svy, subpop(yr2022sample): mean pregnant_REF100 Jun24Dec31
estat sd
power oneslope 0 .3820963, sdy(6.143095) sdx(.4208074)

*By age
foreach v of varlist age1829 age3039 age4049 {
	replace `v'=0 if sexvar==1|_ageg5yr>=7 & _ageg5yr<=13
}
foreach v of varlist age1829 age3039 age4049 {
svy, subpop(`v'): reg pregnant_REF100 Jun24Dec31 i.race i._ageg5yr i._educa i.new_income
est store `v'
}
coefplot age1829 age3039 age4049, keep(Jun24Dec31) name(byage, replace) title("By Age") vertical yline(0) legend(off) xtitle(" ") coeflabels(Jun24Dec31=" ") xlabel(.75 "18-29" 1 "30-39" 1.25 "40-49") ytitle("Coefficient on June24-Dec31")

estout age1829 age3039 age4049 using Appendix.txt, append cells(b(fmt(3)) se(fmt(3)) p(fmt(3))) stats(r2 N_sub, fmt(%9.3f %9.0g)) delimit(|) lab title("Table SB6a")

*By race/ethnicity
foreach v of varlist white black hispanic {
	replace `v'=0 if sexvar==1|_ageg5yr>=7 & _ageg5yr<=13
}

foreach v of varlist white black hispanic {
svy, subpop(`v'): reg pregnant_REF100 Jun24Dec31 i.race i._ageg5yr i._educa i.new_income
est store `v'
}

coefplot white black hispanic, keep(Jun24Dec31) name(byrace, replace) title("By Race/Ethnicity") vertical yline(0) legend(off) xtitle(" ") coeflabels(Jun24Dec31=" ") xlabel(.75 "White" 1 "Black" 1.25 "Hispanic" ) ytitle("Coefficient on June24-Dec31")

estout white black hispanic using Appendix.txt, append cells(b(fmt(3)) se(fmt(3)) p(fmt(3))) stats(r2 N_sub, fmt(%9.3f %9.0g)) delimit(|) lab title("Table SB6b")

*By income
recode income3 (1/5=1)(6/99=0)(else=.), gen(incQ1)
recode income3 (6/7=1)(1/5 8/99=0)(else=.), gen(incQ2)
recode income3 (8/9=1)(1/7 10/99=0)(else=.), gen(incQ3)
recode income3 (10/11=1)(1/9 12/99=0)(else=.), gen(incQ4)

foreach v of varlist incQ1 incQ2 incQ3 incQ4 {
	replace `v'=0 if sexvar==1|_ageg5yr>=7 & _ageg5yr<=13
}

foreach v of varlist incQ1 incQ2 incQ3 incQ4 {
svy, subpop(`v'): reg pregnant_REF100 Jun24Dec31 i.race i._ageg5yr i._educa i.new_income
est store `v'
}

coefplot incQ1 incQ2 incQ3 incQ4, keep(Jun24Dec31) name(byincome, replace) title("By Income Quartiles") vertical yline(0) legend(off) xtitle(" ") coeflabels(Jun24Dec31=" ") xlabel(.7 "Q1" .9 "Q2" 1.1 "Q3" 1.3 "Q4") ytitle("Coefficient on June24-Dec31")

estout incQ1 incQ2 incQ3 incQ4 using Appendix.txt, append cells(b(fmt(3)) se(fmt(3)) p(fmt(3))) stats(r2 N_sub, fmt(%9.3f %9.0g)) delimit(|) lab title("Table SB6c")

*By education
foreach v of varlist hsorless somecol college {
	replace `v'=0 if sexvar==1|_ageg5yr>=7 & _ageg5yr<=13
}

foreach v of varlist hsorless somecol college {
svy, subpop(`v'): reg pregnant_REF100 Jun24Dec31 i.race i._ageg5yr i._educa i.new_income
est store `v'
}

coefplot hsorless somecol college, keep(Jun24Dec31) name(byeduc, replace) title("By Education") vertical plotlabels("HS or less" "Some Col." "College")  legend(row(1)) yline(0)

coefplot hsorless somecol college, keep(Jun24Dec31) name(byeduc, replace) title("By Education") vertical yline(0) legend(off) xtitle(" ") coeflabels(Jun24Dec31=" ") xlabel(.75 `" "High School" "or less" "' 1 `" "Some" "College" "' 1.25 `" "BA" "or more" "', labsize(small)) ytitle("Coefficient on June24-Dec31")

estout hsorless somecol college using Appendix.txt, append cells(b(fmt(3)) se(fmt(3)) p(fmt(3))) stats(r2 N_sub, fmt(%9.3f %9.0g)) delimit(|) lab title("Table SB6d")

**********FIGURE 2**********
graph combine byage byrace byincome byeduc, ycommon ysize(3) xsize(4)
**********FIGURE 2**********


*By urban/rural
recode _metstat (1=1) (2=0)(else=.), gen(metrocounties)
recode _metstat (1=0) (2=1)(else=.), gen(nonmetrocounties)
recode _urbstat (1=1) (2=0)(else=.), gen(urban)
recode _urbstat (1=0) (2=1)(else=.), gen(rural)

foreach v in metrocounties nonmetrocounties urban rural {
	svy, subpop(`v'): reg pregnant_REF100 Jun24Dec31 i.race i._ageg5yr i._educa i.new_income
est store `v'
}

estout metrocounties nonmetrocounties urban rural using Appendix.txt, append cells(b(fmt(3)) se(fmt(3)) p(fmt(3))) stats(r2 N_sub, fmt(%9.3f %9.0g)) delimit(|) lab title("Table SB7")


******************************
**********BY STATE POLICY ENVIRONMENT**********
gen state_fips_number = _state
gen state_month = state_fips_number*100+ month_no
gen stateab = state_fips_number
lab def stateab 1"AL"
lab def stateab 2"AK" , modify
lab def stateab 4"AZ" , modify
lab def stateab 5"AR" , modify
lab def stateab 6"CA" , modify
lab def stateab 8"CO" , modify
lab def stateab 9"CT" , modify
lab def stateab 10"DE" , modify
lab def stateab 12"FL" , modify
lab def stateab 13"GA" , modify
lab def stateab 15"HI" , modify
lab def stateab 16"ID" , modify
lab def stateab 17"IL" , modify
lab def stateab 18"IN" , modify
lab def stateab 19"IA" , modify
lab def stateab 20"KS" , modify
lab def stateab 21"KY" , modify
lab def stateab 22"LA" , modify
lab def stateab 23"ME" , modify
lab def stateab 24"MD" , modify
lab def stateab 25"MA" , modify
lab def stateab 26"MI" , modify
lab def stateab 27"MN" , modify
lab def stateab 28"MS" , modify
lab def stateab 29"MO" , modify
lab def stateab 30"MT" , modify
lab def stateab 31"NE" , modify
lab def stateab 32"NV" , modify
lab def stateab 33"NH" , modify
lab def stateab 34"NJ" , modify
lab def stateab 35"NM" , modify
lab def stateab 36"NY" , modify
lab def stateab 37"NC" , modify
lab def stateab 38"ND" , modify
lab def stateab 39"OH" , modify
lab def stateab 40"OK" , modify
lab def stateab 41"OR" , modify
lab def stateab 42"PA" , modify
lab def stateab 44"RI" , modify
lab def stateab 45"SC" , modify
lab def stateab 46"SD" , modify
lab def stateab 47"TN" , modify
lab def stateab 48"TX" , modify
lab def stateab 49"UT" , modify
lab def stateab 50"VT" , modify
lab def stateab 51"VA" , modify
lab def stateab 53"WA" , modify
lab def stateab 54"WV" , modify
lab def stateab 55"WI" , modify
lab def stateab 56"WY" , modify
lab def stateab 11"DC" , modify
lab val stateab stateab

//POST ROE STATUS
*ASSURED
recode _state (2 6 8 9 10 11 15 17 23 24 25 27 32 33 34 35 36 41 42 44 50 51 53=1 "Assured")(1 4 5 12 13 16 17 18 19 20 21 22 26 28 29 30 31 37 38 39 40 45 46 47 48 49 54 55 56=0 "Contested or banned")(else=.), gen(assured)
lab var assured "Assured"
recode assured(1=0 "assured")(0=1 "contestedorbanned")(else=.), gen(contestedorbanned)
lab var contestedorbanned "Contested or banned"

svy, subpop(assured): reg pregnant_REF100 Jun24Dec31 i.race i._ageg5yr i._educa i.new_income
est store assuredsubpop
svy, subpop(contestedorbanned): reg pregnant_REF100 Jun24Dec31 i.race i._ageg5yr i._educa i.new_income
est store contestedorbannedsubpop

suest assuredsubpop contestedorbannedsubpop
test [assuredsubpop]Jun24Dec31=[contestedorbannedsubpop]Jun24Dec31

coefplot assuredsubpop contestedorbannedsubpop, keep(Jun24Dec31) name(statepolicy, replace) title("State Policy Environment" " ") vertical yline(0) legend(off) xtitle(" ") coeflabels(Jun24Dec31=" ") xlabel(.8 "Assured" 1.175 "Contested/Restricted", labsize(large)) ytitle("Coefficient on June24-Dec31")

**********BY AGE**********
recode _ageg5yr (1 2 3 4=1)(5/99=0)(else=.), gen(age1839)
replace age1839=0 if sexvar==1|_ageg5yr>=7 & _ageg5yr<=13
replace age4049=0 if sexvar==1|_ageg5yr>=7 & _ageg5yr<=13

**********TABLE 4**********
gen age1839assured = age1839
replace age1839assured =0 if assured~=1
 
gen age1839contestedorbanned= age1839
replace age1839contestedorbanned =0 if contestedorbanned~=1

gen age4049assured = age4049
replace age4049assured =0 if assured~=1

gen age4049contestedorbanned= age4049
replace age4049contestedorbanned =0 if contestedorbanned~=1

foreach v of varlist age1839assured age1839contestedorbanned  age4049assured age4049contestedorbanned { 
svy, subpop(`v'): reg pregnant_REF100 Jun24Dec31 i.race i._ageg5yr i._educa i.new_income
est store `v'
}

coefplot age1839assured age1839contestedorbanned, keep(Jun24Dec31) name(statepolicy1839, replace) title("State Policy Environment" "Women Ages 18-39") vertical yline(0) legend(off) xtitle(" ") coeflabels(Jun24Dec31=" ") xlabel(.8 "Assured" 1.175 "Contested/Restricted", labsize(large)) ytitle("Coefficient on June24-Dec31")

coefplot age4049assured age4049contestedorbanned, keep(Jun24Dec31) name(statepolicy4049, replace) title("State Policy Environment" "Women Ages 40-49") vertical yline(0) legend(off) xtitle(" ") coeflabels(Jun24Dec31=" ") xlabel(.8 "Assured" 1.175 "Contested/Restricted", labsize(large)) ytitle("Coefficient on June24-Dec31")

**********FIGURE 3**********
graph combine statepolicy statepolicy1839 statepolicy4049, ycommon xsize(4) ysize(1.5) row(1)
graph export Figure3.tif, replace width(4000)
**********FIGURE 3**********

estout assuredsubpop contestedorbannedsubpop age1839assured age1839contestedorbanned  age4049assured age4049contestedorbanned using Appendix.txt, append cells(b(fmt(3)) se(fmt(3)) p(fmt(3))) stats(r2 N_sub, fmt(%9.3f %9.0g)) delimit(|) lab title("Table SB8")


**********APPENDIX: ALTERNATIVE CODING**********
**********CODING SCHEME 2**********
gen triggerban = contestedorbanned
foreach v in 4 12 13 18 19 20 26 30 31 37 39 45 54 55 {
replace triggerban = 0 if state_fips_number==`v'
}
gen contested_2 = contestedorbanned
replace contested_2 = 0 if triggerban==1
svy, subpop(contested_2): reg pregnant_REF100 Jun24Dec31 i.race i._ageg5yr i._educa i.new_income
est store contested_2_subpop
svy, subpop(triggerban): reg pregnant_REF100 Jun24Dec31 i.race i._ageg5yr i._educa i.new_income
est store triggerban_subpop

**********CODING SCHEME **********
gen triggerbanenforced = triggerban
replace triggerbanenforced = 0 if state_fips_number== 38|state_fips_number== 49|state_fips_number== 56
gen contested_3 = contested_2
replace contested_3 = 1 if state_fips_number==38
replace contested_3 = 1 if state_fips_number==49
replace contested_3 = 1 if state_fips_number==56

svy, subpop(contested_3): reg pregnant_REF100 Jun24Dec31 i.race i._ageg5yr i._educa i.new_income
est store contested_3_subpop
svy, subpop(triggerbanenforced): reg pregnant_REF100 Jun24Dec31 i.race i._ageg5yr i._educa i.new_income
est store triggerbanenforced_subpop

coefplot assuredsubpop contestedorbannedsubpop, keep(Jun24Dec31) name(statecoding1, replace) title("State Policy Environment""Coding Scheme 1") vertical yline(0) legend(off) xtitle(" ") coeflabels(Jun24Dec31=" ") xlabel(.8 "Assured" 1.175 "Contested/Restricted") ytitle("Coefficient on June24-Dec31")

coefplot assuredsubpop contested_2_subpop triggerban_subpop, keep(Jun24Dec31) name(statecoding2, replace) title("State Policy Environment""Coding Scheme 2") vertical yline(0) legend(off) xtitle(" ") coeflabels(Jun24Dec31=" ") xlabel(.75 "Assured" 1 "Contested_2" 1.25"     Trigger Ban") ytitle("Coefficient on June24-Dec31")

coefplot assuredsubpop contested_3_subpop triggerbanenforced_subpop, keep(Jun24Dec31) name(statecoding3, replace) title("State Policy Environment""Coding Scheme 3") vertical yline(0) legend(off) xtitle(" ") coeflabels(Jun24Dec31=" ") xlabel(.75 "Assured" 1 "Contested_3" 1.25"     Ban Enforced") ytitle("Coefficient on June24-Dec31")

graph combine statecoding1 statecoding2 statecoding3, row(1) ysize(3.5) xsize(8) ycommon
*APPENDIX FIGURE SC1
graph export statecodingschemes.tif, replace width(800) height(350)

**********PREDICTED VALUES FOR APPENDIX TABLE SC2**********
est restore assuredsubpop
gen assured_subpop_sample=e(sample)
predict phat_assured
predict phat_assured_se, stdp
svy, subpop(assured_subpop_sample): mean phat_assured , over(Jun24Dec31)

est restore contestedorbannedsubpop
gen contestedorbanned_subpop=e(sample)
predict phat_contestedorbanned
predict phat_contestedorbanned_se, stdp
svy, subpop(contestedorbanned_subpop): mean phat_contestedorbanned, over(Jun24Dec31)

est restore contested_2_subpop
gen contested_2_subpop=e(sample)
predict phat_contested_2
predict phat_contested_2_se, stdp
svy, subpop(contested_2_subpop): mean phat_contested_2, over(Jun24Dec31)

est restore triggerban_subpop
gen triggerban_subpop=e(sample)
predict phat_triggerban_subpop
predict phat_triggerban_subpop_se, stdp
svy, subpop(triggerban_subpop): mean phat_triggerban_subpop, over(Jun24Dec31)

est restore contested_3_subpop
gen contested_3_subpop=e(sample) 
predict phat_contested_3
predict phat_contested_3_se, stdp
svy, subpop(contested_3_subpop): mean phat_contested_3, over(Jun24Dec31)

est restore triggerbanenforced_subpop
gen triggerbanenforced_subpop=e(sample)
predict phat_triggerbanenforced_subpop
predict phat_triggerbanenforced_se, stdp
svy, subpop(triggerbanenforced_subpop): mean phat_triggerbanenforced_subpop, over(Jun24Dec31)

log close
